RWTH - Mindstorms NXT Toolbox

WaitForMotor

Pauses execution until specific motor is not running anymore.

Contents

Syntax

WaitForMotor(port)

WaitForMotor(port, time)

WaitForMotor(port, time, handle)

Description

WaitForMotor(port) pauses other MALTAB executions until the motor connected to the given port is not running anymore. The value port can be addressed by the symbolic constants MOTOR_A, MOTOR_B and MOTOR_C analog to the labeling on the NXT Brick.

WaitForMotor(port, time) specifies a maximum timeout (waiting time in seconds) until execution will be continued anyway.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Note:

Be careful not using a timeout, wrong motor settings or blocked motors can lead to an infinite loop and cause the application to hang...

This function uses busy waiting, i.e. is constantly polling the specified motor. Hence Bluetooth timeouts can lead to delays in this function, meaning that execution of your program might continue slightly later than expected (depending on Bluetooth connection quality). Be aware of this (for example by setting an angle limit using SetAngleLimit) to take precautions.

Example

   SetMotor(MOTOR_B);
   	SetPower(-55);
   	SetAngleLimit(1200);
   SendMotorSettings();

   WaitForMotor(MOTOR_A);

   StopMotor(MOTOR_B, 'brake');

See also

SendMotorSettings, StopMotor, MOTOR_A, MOTOR_B, MOTOR_C

Signature